Yacon.widget.TPicture = function(conText){
	
	Yacon.apply(this,conText);
	
	if(this.view){
		this.view.src = getAbsolutePath(this.view.src);
	}
	
	if(this.src){
		this.src = getAbsolutePath(this.src);
	}
	
};

Yacon.widget.TPicture.prototype = {
	
	
	getHtml : function(){
		
		var html = "";
		
		html += "<a href='javascript:void(0);' class='thumbnail' pic-idx='"+this.picIdx+"'>";
		
		html += "<img src='"+this.view.src+"' alt='"+this.view.alt+"' pic-idx='"+this.picIdx+"' ";
		
		html += " style='width:100%;height:"+this.parent.view.picHeight+"' ";
		
		html += "/>";
		
		html += "</a>";
		
		return html;
		
	},
	
	getWindowHtml: function(){
		
	    var html = "";
		
	    html += "<div class='big-image'>"			
		html += "<div class='modal fade' id='"+this.id+"_pic_windows' tabindex='-1' role='dialog'>";	
		html += "<div class='modal-dialog' role='document' ";
		
		if(!Yacon.isEmpty(this.width)){
			html += " style='width:"+this.width+"' ";
		}
			
		html += ">";
		
		html += "<div class='modal-content'>";
		html += "<div class='modal-body' style='padding:0px;'>";		
		html += "<img src='"+this.src+"' alt='"+this.alt+"'" ;
		
		if(!Yacon.isEmpty(this.width)){
			html += " style='width:"+this.width+"' ";
		}
	
		html +=	" />";		
		html += "</div>";
		html += "</div>";
		html += "</div>";
		html += "</div>";	
		html += "</div>";
		
		return html;
			
	},
	
	showWindow:function(){
		
		var self = this;
		
		$("body").append(this.getWindowHtml());
		$("#"+self.id+"_pic_windows").modal('show');
		
		$("#"+self.id+"_pic_windows").on('shown.bs.modal',function (e) {
			
			if(!Yacon.isEmpty(self.maxWidth)){
				var im = new Image();
			　　    im.src = self.src;
			　　    var actWd = im.width;		　　    
			　　    var maxWd = Yacon.getWidthNumber(self.maxWidth);
			　　    
			　　    if(actWd > maxWd){		　　    	
			　　    	$(this).find(".modal-dialog").css("width",maxWd+"px");
			　　    	$(this).find("img").css("width",maxWd+"px");　　    	
			　　    }

			}
			
			$('#'+self.id+"_pic_windows").on('hidden.bs.modal', function (e) {
				
				$('#'+self.id+"_pic_windows").parent().remove();
				
				var parentSize = $(".modal .modal-dialog").length;				
				if(parentSize > 0){
					$("body").addClass("modal-open");
				}
				
			});
		});
	},
	
	closeWindow:function(){
		$("#"+this.id+"_pic_windows").modal('hide');
	}

};